package net;

import java.util.HashMap;
import java.util.Map;

import org.jboss.netty.buffer.ChannelBuffer;

public class MessageDispatcher {
	public Map<String, IMessageHandler> handlers = new HashMap<String, IMessageHandler>();
//	public IVersionChecker checker; 
	
//	public MessageDispatcher(IVersionChecker checker) {
		
//	}
	
	public void register(IMessageHandler handler) {
		handlers.put(handler.getClass().getSimpleName(), handler);
	}
	
	public boolean dispatch(ClientContext context, String msg, ChannelBuffer data) throws Exception {
		return handlers.get(msg).handle(context, data);
	}
}
